package com.cjg.lock;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class demo02 {
    public static void main(String[] args) {
        phone1 phone = new phone1();
        new Thread(()->{
            phone.qq();
        }).start();
    }
    }


class phone1{
    private Lock lock =new ReentrantLock();
    public synchronized void call(){
        lock.lock();
        try {
        System.out.println("call"); }
        catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }

    public synchronized void qq(){
        lock.lock();
        try {
            System.out.println("qq");
            call();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}